package com.cnpc.rightslogan.controller;

import com.alibaba.fastjson.JSON;
import com.cnpc.rightslogan.entity.DictionaryData;
import com.cnpc.rightslogan.service.IDictionaryDataService;
import com.cnpc.rightslogan.utils.common.BaseController;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * Created by Administrator on 2017/9/13.
 * 测试服务之间调用添加了/api  /api/** 不会参与登录验证
 */
@RestController
@RequestMapping("/api/dictionaryData")
@Api("DictionaryDataController相关的api")
@Slf4j
public class DictionaryDataController extends BaseController {

    @Autowired
    private IDictionaryDataService dictionaryDataServiceImpl;

    @ApiOperation(value = "获取所有数据，分页获取", notes = "获取所有数据")
    @ResponseBody
    @PostMapping("getDictionaryDataList")
    public PageInfo<DictionaryData> getDictionaryDataList(@RequestBody @ApiParam(name = "json", value = "分页对象及User对象json串") String json) {
        PageInfo pageInfo = JSON.parseObject(json, PageInfo.class);
        DictionaryData dictionaryData = JSON.parseObject(json, DictionaryData.class);
        log.info("DictionaryData模块-获取所有数据");
        return dictionaryDataServiceImpl.getDictionaryDataList(pageInfo.getPageNum(), pageInfo.getPageSize(), dictionaryData);
    }
}